package main

import (
	"log"

	"os"

	_ "gin.andbridge/boot"
	"gin.andbridge/core/middleware"
	"gin.andbridge/core/router"
	"gin.andbridge/global"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
	"github.com/swaggo/swag/example/basic/docs"
)

// @title example
// @version 1.0
// @description example

// @host localhost:8088
// @BasePath /swagger/*any
func main() {
	gin.SetMode(global.Server.RunMode)
	Engine := gin.New()
	// 日志配置
	file, err := os.Create("gin.log")
	if err != nil {
		log.Panicf("日志初始化失败:%v", err)
	}
	log.SetOutput(file)
	Engine.Use(gin.Logger())
	Engine.Use(gin.Recovery())
	Engine.Use(middleware.Cors())
	// 初始化路由
	router.RouterInit(Engine)
	docs.SwaggerInfo.BasePath = "/"
	Engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	log.Printf("服务启动成功了，快来访问我呀！！！")
	Engine.Run(global.Server.HostPort)
}
